#ifndef __ADAPT_H__
#define __ADAPT_H__

#include <stdint.h> 
#include <stdbool.h>
#include "fw_interface.h"
#include  <time.h>
#include "misc/misc_api.h"

#include "service/include/swei_alarm.h"



#ifdef __cplusplus
extern "C" {
#endif

#define COMPILE_DATE __DATE__  // compile date.
#define COMPILE_TIME __TIME__  // compile time.

#define usleep(x)       vTaskDelay(_MS2TICKS((x+999)/1000))


/* sleep/wakeup vot module id */
#define GSENSOR_TYPE        1


/* global macro definition, error codes for other modules can be defined in their own modules */
#define  ERROR     -1
#define  TRUE       1
#define  FALSE      0
#define  SUCCESS    0
#define  FAILURE    -1


extern int fw_gsensor_check(void);

extern int fw_gsensor_set_measure_range(int nRange);   /* nRange  only 2  ,4   , 8  ,16 */

extern int fw_gsensor_set_sampled_frequency(int frequency); //frequency  100, 200, 400;

extern int swei_netProtocol_send_gsensor_warning_msg(swei_alarm_id_e alarm_id);

extern int tbox_power_set_business_flag(char type, uint8_t value);

extern char get_power_business_flag(void);

extern bool tbox_get_reboot_flag(void);

extern int swei_gps_get_info(struct FW_GPS_INFO_STRU *info);

extern time_t get_utctime_timestamp(char time_arr[]);

extern int tbox_power_quit_sleep(void);

extern int swei_get_sys_run_state(char type);


/* set-get sys run state enum */
typedef enum
{
    CONNECT_SERVER_STATE  = 0x00,
    GPS_FIXED_STATE       = 0x01,
    ACC_STATE             = 0x02,
    DEVICE_BING_STATE     = 0x03,
    DEVICE_POWER_STATE    = 0x04,
    DEVIDE_OTA_STATE      = 0x05,
    DEVIDE_ACTIVATE_STATE = 0x06 //激活状态
}set_get_run_state_enum;

int swei_get_device_info(uint8_t type, uint8_t *p_get_info);

/**
 * @description: 获取设备的时间戳
 * @return {*}
 * @Date: 2023-08-10 16:38:23
 * @modification: 
 */
int swei_get_dev_timestamp(void);


/**
 * @description: 执行系统命令
 * @param {char} *cmd 命令字符串
 * @return {0：ok  others:err}
 */
int tbox_system_exec(const char* cmd);


#ifdef __cplusplus
}
#endif

#endif

